package team.sun.sss.dao.sturoutine;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import team.sun.sss.pojo.student.Student1;
import team.sun.sss.pojo.sturoutine.SrStaycome;

import java.util.List;

@Mapper
@Repository
public interface SrStaycomeDao {


    @Select("select * from sr_staycome where stu_id=#{stuId}")
    List<SrStaycome> getStayList(int stuId);//查询学生个人信息（留校）

    @Select("select * from sr_staycome where stu_id=#{stuId}")
    List<SrStaycome>getComeList(int stuId);//查询学生个人信息（返校）

    @Select("select * from sr_staycome where staycome_num=#{staycome_num}")
    List<SrStaycome> getSrComeList(int staycome_num);//查询学生（返校)申请信息

    @Select("select * from sr_staycome where staycome_num=#{staycome_num}")
    List<SrStaycome> getSrStayList(int staycome_num);//查询学生(留校)申请信息

    @Select("select student.stu_id,student.stu_phone,sr_staycome.* from student,sr_staycome where student.stu_id=sr_staycome.stu_id and staycome_type=2")
    List<SrStaycome> getStuComeList(int stuId);//学生表和返校表联立查询(学生)

    @Select("select student.*,sr_staycome.* from student,sr_staycome where student.stu_id=sr_staycome.stu_id and staycome_type=2")
    List<SrStaycome> getStaffComeList();//学生表和返校表联立查询(教师)

    @Select("select student.*,sr_staycome.* from student,sr_staycome where staycome_time=#{staycomeTime} and student.stu_id=sr_staycome.stu_id")
    List<SrStaycome> getComeSelect(String staycomeTime);//用申请时间查询学生返校相关信息

    @Select("select student.*,sr_staycome.* from student,sr_staycome where staycome_time=#{staycomeTime} and student.stu_id=sr_staycome.stu_id")
    List<SrStaycome> getStaySelect(String staycomeTime);//用申请时间查询学生留校相关信息

    @Select("select student.stu_id,student.stu_phone,sr_staycome.* from student,sr_staycome where student.stu_id=sr_staycome.stu_id and staycome_type=1 ")
    List<SrStaycome> getStuStayList(int stuId);//学生表和留校表联立查询(学生)

    @Select("select student.*,sr_staycome.* from student,sr_staycome where student.stu_id=sr_staycome.stu_id and staycome_type=1")
    List<SrStaycome> getStaffStayList();//学生表和留校表联立查询(教师)



    @Insert("insert into sr_staycome(stu_id,staycome_time,staycome_type,staycome_reason,staycome_applystate) values(#{stuId},#{staycomeTime},\"2\",#{staycomeReason},\"1\")")
    int addSrCome(int stuId,String staycomeTime,String staycomeReason);//创建返校信息

    @Insert("insert into sr_staycome(stu_id,staycome_time,staycome_type,staycome_reason,staycome_applystate) values(#{stuId},#{staycomeTime},\"1\",#{staycomeReason},\"1\")")
    int addSrStay(int stuId,String staycomeTime,String staycomeReason);//创建留校信息


    @Update("update sr_staycome set staycome_time=#{StaycomeTime},staycome_reason=#{StaycomeReason} where staycome_num=#{num}")
    int updateCome(String StaycomeTime,String StaycomeReason,int num );//对返校信息进行修改

    @Update("update sr_staycome set staycome_applystate=#{staycomeState} where staycome_num=#{num}  ")
    int staffUpdateCome(String staycomeState,int num);//教师审核学生返校申请信息
    @Update("update sr_staycome set staycome_applystate=#{staycomeState} where staycome_num=#{num}  ")
    int staffUpdateStay(String staycomeState,int num);//教师审核学生留校申请信息

    @Update("update sr_staycome set staycome_time=#{StaycomeTime},staycome_reason=#{StaycomeReason} where staycome_num=#{num}")
    int updateStay(String StaycomeTime,String StaycomeReason,int num );//对留校信息进行修改



    @Delete("delete from sr_staycome where staycome_num=#{staycome_num}")
    int deleteSrStaycome( int num);//删除学生返校/留校申请信息


}
